//
//  GCTopicHeaderCollectionHeader.m
//  GoldChampion
//
//  Created by Mac on 2018/4/12.
//  Copyright © 2018年 stoneobs@icloud.com. All rights reserved.
//

#import "GCTopicHeaderCollectionHeader.h"
@interface GCTopicHeaderCollectionHeader()
@property(nonatomic, strong) UIImageView                     *bannerImageView;
@property(nonatomic, strong) STLabel                     *desLable;
@property(nonatomic, strong) STLabel                     *joinLable;
@property(nonatomic, strong) STLabel                     *workLable;
@property(nonatomic, strong) STLabel                     *likeLable;

@property(nonatomic, strong) UIImageView                     *imageView1;
@property(nonatomic, strong) UIImageView                     *imageView2;
@property(nonatomic, strong) UIImageView                     *imageView3;
@property(nonatomic, strong) UIImageView                     *imageView4;
@end
@implementation GCTopicHeaderCollectionHeader
- (instancetype)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        [self configSubView];
    }
    return self;
}
#pragma mark --subView
- (void)configSubView{
    
    self.backgroundColor = [UIColor whiteColor];
    self.bannerImageView = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, UIScreenWidth, 130)];
    self.bannerImageView.image = [UIImage imageNamed:@"zhijianyunhe"];
    [self addSubview:self.bannerImageView];
    
    NSString * conten = @"传承运河文化，记录运河风情。\n金冠活动中心发起#指尖上的大运河#记录活动。\n你可能身处运河文化带却不自知，\n你可能活在老祖宗留下来的遗产下却没好好保护。\n这一次我们为大家科普，呼吁大家保护和传承....";
    self.desLable = [[STLabel alloc] initWithFrame:CGRectMake(15, 10 + self.bannerImageView.bottom, UIScreenWidth - 15 , 90)
                                                     text:conten
                                                textColor:FirstTextColor
                                                     font:14
                                              isSizetoFit:NO
                                            textAlignment:NSTextAlignmentLeft];
    [self addSubview:self.desLable];
    
    UIView * line = [[UIView alloc] initWithFrame:CGRectMake(0, self.desLable.bottom+10, UIScreenWidth, 0.5)];
    line.backgroundColor = TM_lineColor;
    [self addSubview:line];
    
    self.joinButton = [[STButton alloc] initWithFrame:CGRectMake(0, line.bottom + 22, 80, 26)
                                                     title:@"参与话题"
                                                titleColor:[UIColor whiteColor]
                                                 titleFont:14
                                              cornerRadius:13
                                           backgroundColor:TM_redColor
                                           backgroundImage:nil
                                                     image:nil];
    self.joinButton.contentHorizontalAlignment = UIControlContentHorizontalAlignmentCenter;
    self.joinButton.right = UIScreenWidth - 15;
    
    [self addSubview:self.joinButton];
    
    self.joinLable = [STLabel new];
    self.workLable = [STLabel new];
    self.likeLable = [STLabel new];
    CGFloat viewWith = self.joinButton.left / 3;
    UIView * joinView = [self viewWithLable:self.joinLable title:@"参与" value:@"12.6w" witdh:viewWith];
    joinView.top = line.bottom;
    joinView.left = 0  * viewWith;
    [self addSubview:joinView];
    
    UIView * workView = [self viewWithLable:self.workLable title:@"作品" value:@"2.6w" witdh:viewWith];
    workView.top = line.bottom;
    workView.left = 1  * viewWith;
    [self addSubview:workView];
    
    UIView * likeView = [self viewWithLable:self.likeLable title:@"喜欢" value:@"3.6w" witdh:viewWith];
    likeView.top = line.bottom;
    likeView.left = 2  * viewWith;
    [self addSubview:likeView];
    
    self.joinButton.centerY = likeView.centerY;
    
    UIView * grawView = [[UIView alloc] initWithFrame:CGRectMake(0, likeView.bottom, UIScreenWidth, 10)];
    grawView.backgroundColor = TM_backgroundColor;
    [self addSubview:grawView];
    
    STLabel * titleLable = [[STLabel alloc] initWithFrame:CGRectMake(15, grawView.bottom, 200, 44)
                                                     text:@"精选"
                                                textColor:SecendTextColor
                                                     font:16
                                              isSizetoFit:NO
                                            textAlignment:NSTextAlignmentLeft];
    [self addSubview:titleLable];
    
    
    CGFloat imageViewWith = (UIScreenWidth - 30 - 6)/4;
    
    
    self.imageView1 = [[UIImageView alloc] initWithFrame:CGRectMake(15, titleLable.bottom, imageViewWith, imageViewWith)];
    self.imageView1.image = [UIImage imageNamed:@"RENWU"];
    [self addSubview:self.imageView1];
    
    
    self.imageView2 = [[UIImageView alloc] initWithFrame:CGRectMake(self.imageView1.right + 2, titleLable.bottom, imageViewWith, imageViewWith)];
    self.imageView2.image = [UIImage imageNamed:@"wenquan"];
    [self addSubview:self.imageView2];
    
    
    self.imageView3 = [[UIImageView alloc] initWithFrame:CGRectMake(self.imageView2.right + 2, titleLable.bottom , imageViewWith, imageViewWith)];
    self.imageView3.image = [UIImage imageNamed:@"YUNHE2"];
    [self addSubview:self.imageView3];
    
    self.imageView4 = [[UIImageView alloc] initWithFrame:CGRectMake(self.imageView3.right + 2, titleLable.bottom , imageViewWith, imageViewWith)];
    self.imageView4.image = [UIImage imageNamed:@"wenquan"];
    [self addSubview:self.imageView4];
    
    
    STLabel * newLable = [[STLabel alloc] initWithFrame:CGRectMake(15, self.imageView4.bottom, 200, 44)
                                                     text:@"最新"
                                                textColor:SecendTextColor
                                                     font:16
                                              isSizetoFit:NO
                                            textAlignment:NSTextAlignmentLeft];
    [self addSubview:newLable];
    
    NSLog(@"height - %f",newLable.bottom);
    
}
- (UIView*)viewWithLable:(STLabel*)lable title:(NSString*)title value:(NSString*)value witdh:(CGFloat)witdh{
    UIView * view = [[UIView alloc] initWithFrame:CGRectMake(0, 0, witdh, 70)];
    STLabel * titleLable = [[STLabel alloc] initWithFrame:CGRectMake(0, 15, witdh, 20)
                                                     text:title
                                                textColor:SecendTextColor
                                                     font:14
                                              isSizetoFit:NO
                                            textAlignment:NSTextAlignmentCenter];
    [view addSubview:titleLable];
    
    lable.frame = CGRectMake(0, titleLable.bottom, witdh, 20);
    lable.textColor = SecendTextColor;
    lable.font = [UIFont systemFontOfSize:14];
    lable.text = value;
    lable.textAlignment = NSTextAlignmentCenter;
    [view addSubview:lable];
    return view;
}
@end
